package com.wn.ziroom.config;

import com.wn.ziroom.interceptor.AjaxLoginInterceptor;
import com.wn.ziroom.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    private LoginInterceptor loginInterceptor;

    @Autowired
    private AjaxLoginInterceptor ajaxLoginInterceptor;

    @Autowired
    public void setLoginInterceptor(LoginInterceptor loginInterceptor) {
        this.loginInterceptor = loginInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        List<String> ajaxAddList = new ArrayList<>();
        ajaxAddList.add("/orderRoom/addOrder");


//
        List<String> excludeList = new ArrayList<>();
        excludeList.add("/ziroom_portal/user/goTouserInfo");
      /*  excludeList.add("/ziroom_portal/user/logout");
        excludeList.add("/ziroom_portal/user/login");
        excludeList.add("/ziroom_portal/user/loginmessage");
        excludeList.add("/ziroom_portal/user/message");
        excludeList.add("/ziroom_portal/user/register");
        excludeList.add("/ziroom_portal/user/loginUser");
        excludeList.add("/showRoom.html");
        excludeList.add("/room/**");
        excludeList.add("/orderRoom/addOrder");
        excludeList.add("/ziroom_portal/user/login.html");
        excludeList.add("/ziroom_portal/user/login");
        excludeList.add("/ziroom_portal/user/**");
        excludeList.add("/css/**");
        excludeList.add("/images/**");
        excludeList.add("/img/**");
        excludeList.add("/js/**");
        excludeList.add("/ziroom_portal/owner/login");
        excludeList.add("/ziroom_portal/owner/message");
        excludeList.add("/ziroom_portal/owner/ownerLogin");
        excludeList.add("");*/





//        List<String> ajaxExcludeList = new ArrayList<>();
//        ajaxExcludeList.add("/showRoom.html");
//        ajaxExcludeList.add("/room/**");






        registry.addInterceptor(loginInterceptor).addPathPatterns(excludeList);
        registry.addInterceptor(ajaxLoginInterceptor).addPathPatterns(ajaxAddList);

    }
}
